<!DOCTYPE html>
<html>
<head>
	<title>管理登录</title>
	<link rel="stylesheet" href="/static/css/base.css" type="text/css" />
	<link rel="stylesheet" href="/static/css/caipiao_3.css" type="text/css" />
	<link rel="stylesheet" href="/static/css/icon.css" type="text/css" />
	<script src="/static/js/easydialog.js" type="text/javascript"></script>
  	<link rel="stylesheet" href="/static/css/easydialog.css" type="text/css" />
  	<script src="/static/js/jquery.min.js" type="text/javascript"></script>
  	<script src="/static/js/pyqtmock.js" type="text/javascript"></script>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	
	<script type="text/javascript">
	 var lottery;
	    $(document).ready(function(){
	    	$('#cardnumber_input').focus();
	    	$('#money').click(function(){$('.input_keybord').show();});
	    	//$('#password').focus(function(){$('.input_keybord').show();});
	    	//$('#acc_num').blur(function(){$('.input_keybord').show();});
            //$('#password').focus(function(){$('.input_keybord').hide();});
	    	//软键盘数字键
	        $('i.bottom').click(function(){
	            //console.log($(this).children().html());
	            $('#money').val($('#money').val()+$(this).children().html());
	        });

	        //软键盘删除键
	        $('i.dele').click(function(){
	            var c = $('#money').val();
	            $('#money').val(c.slice(0,c.length-1));
	        });

	        //软键盘清空键
	        $('i.rest').click(function(){
	           $('#money').val(''); 
	        });
	        
	        $('body').click(function(){
	        	if(event.target.id=='backbtn'){
	        		return;
	        	}
		    	if($("#bankcard_info").html()==''){
		    		$('#err_msg').html('请先刷银联卡');
		    		start_dialog2('msg_display',2,'tip_time');
		    		$('#cardnumber_input').val('');
		    		$('#cardnumber_input').focus();
		    	}
		    });
	        
	        $('#cardnumber_input').bind('input',function(){
		    	value=$("#cardnumber_input").val();
		    	if(value.length>38){
		    		if(value.indexOf(';')!=-1 && value.indexOf('?')!=-1){
		    			index = value.indexOf(";");
			    		value = value.substring(1,index+7)+"**********"+value.substring(index+17,index+20);
			    		$("#bankcard_info").html(value);
		    		}else{
		    			$('#err_msg').html('磁条卡错误，请检查是否消磁');
		    			start_dialog2('msg_display',2,'tip_time');
	                	$('#cardnumber_input').val('');
	                	$('#cardnumber_input').focus();
		    		}
		    	}else if(value.indexOf(';')!=-1 && value.indexOf('?')!=-1){
		    		$('#err_msg').html('非磁条卡输入');
		    		start_dialog2('msg_display',2,'tip_time');
                	$('#cardnumber_input').val('');
                	$('#cardnumber_input').focus();
		    	}
	        });
	    });
	    
	    function start_dialog2(id,autocount,countid,callback){
	        callback = callback || function(){};
	        autocount = autocount || 0;
	        countid = countid || null;
	        easyDialog.close();
	        easyDialog.open({
	            container : id,
	                fixed : true,
	                callback: callback,
	                autocount : autocount,  //开启倒计时
	                countid : countid
	        });
	    }
	    
	    function back_guanli(){
	    	window.location.href="/guanli";
	    }
	    
	    function do_recharge(){
	    	var mac = pyObj.get_if_mac()
	    	var money = $('#money').val();
	    	var card_number = $('#cardnumber_input').val()
	    	result = pyObj.yeepay_consume(money,card_number);
	    	if(result=='00'){ //刷卡成功
	    		$.ajax({
	                type:'POST',
	                dataType:'json',
	                url:'/submit_recharge',
	                data:{
	                	mac : mac,
	                	money:money
	                },
	                success:function(data,status){
	                	$('#cardnumber_input').focus();
	                	$('#err_msg').html('充值成功,账户余额：'+data['balance']);
	                	start_dialog2('msg_display',2,'tip_time');
	                },
	                error:function (req, status, error){
	                	$('#cardnumber_input').focus();
	                	$('#err_msg').html(req.responseText);
	                	start_dialog2('msg_display',2,'tip_time');
	                	pyObj.yeepay_rollback();
	                },
	                complete:function(){
	                	setTimeout("back_guanli()",2000);
	                }
	            });
	    	}else if(result=='14'){
	    		$('#msg_content').html("无效卡");
	    		start_dialog2('err_msg',1,'tip_time');
	    	}else if(result=='54'){
	    		$('#msg_content').html("过期卡");
	    		start_dialog2('err_msg',1,'tip_time');
	    	}else if(result=='55'){
	    		$('#msg_content').html("密码错误");
	    		start_dialog2('err_msg',1,'tip_time');
	    	}else if(result=='31'){
	    		$('#msg_content').html("银联不支持的卡");
	    		start_dialog2('err_msg',1,'tip_time');
	    	}else if(result=='38'){
	    		$('#msg_content').html("密码错误次数过多");
	    		start_dialog2('err_msg',1,'tip_time');
	    	}else if(result=='51'){
	    		$('#msg_content').html("余额不足");
	    		start_dialog2('err_msg',1,'tip_time');
	    	}else if(result=='61'){
	    		$('#msg_content').html("超出限额");
	    		start_dialog2('err_msg',1,'tip_time');
	    	}else if(result=='57'){
	    		$('#msg_content').html("不允许交易，联系支付中心");
	    		start_dialog2('err_msg',1,'tip_time');
	    	}else{
	    		$('#msg_content').html("交易失败");
	    		start_dialog2('msg_display',1,'tip_time');
	    	}
	    }
	    
	function start_input_password(){
		$('.input_keybord').hide();
		card_number = $('#cardnumber_input').val();
		result=pyObj.input_bank_password(card_number);
	}
	
	function start_input_money(){
		pyObj.input_money();
	}
	
    function update_password(status){ //用户输入密码后，在界面上提现出字符
    	if(status==1){
    		value=$(".bankpassword").val()
        	$(".bankpassword").val(value+"*")
    	}else if(status==2){
    		value=$(".bankpassword").val()
        	$(".bankpassword").val("")
    	}
    }
    
    function pinstart_timeout(errorCode){ //输入密码超时
    	if(errorCode == 0){
    		$('#err_msg').html("密码输入超时，请重新输入密码");
    	}else{
    		$('#err_msg').html("密码输入故障，请联系管理员");
    	}
    	start_dialog2('msg_display',2,'tip_time');
    	$(".bankpassword").val("");
    }
  </script>
</head>

<body oncontextmenu="return false">
<div id="guanli_denglu">
<input id="cardnumber_input" type="text" value="" class="scaninput"/>
<span class="guanli_denglu_logo"></span>
      <span class="guanli_chongzhi_title"></span>
      <div id="backbtn" class="back_img right inline" onclick="window.location.href='/guanli'"></div>
 </div>
  
	<div class="daigou_1" style="height:496px;margin-left:459px;width:435px;top:50px;" id="login">
	  <div class="daigou_11" style="height:496px;">
	  	<div class="daigou-info" id="div_card">
	  		<span class="yingka"></span><span>请在右侧卡槽处刷卡</span>
	  		<div style="margin-top:7px;">卡号确认:<font id="bankcard_info" style="color:red;margin-left:5px;font-size:20pt;"></font></div>
	  	</div>
	    
	    <div class="daigou-info" id="div_totalmoney">
	    	<span style="margin-left:15px;">请输入充值金额</span><br>
	    	<input id="money" type="text" class="input" style="margin-top:10px;" readOnly="readonly">元
	    </div><br/>
	    
	    <!-- <div class="daigou-info2" style="margin-top:10px;"><span style="margin-left:15px;">请在右侧卡槽处刷银联卡并输入密码</span></div> -->
	    
	    <div class="daigou-info2" id="div_password"><span style="margin-left:15px;">请输入密码并按确定</span>
	        <div><input id="password" type="password" class="bankpassword" onclick="start_input_password();" maxlength="6"></div>
	        <a id="login_submit" onclick="do_recharge();" class="daigou_ok-button" style="margin-top:10px;margin-left:130px;"></a>
	    </div>
	 </div>
	</div>
    <div class="input_keybord" style="display:none;top:-420px;left:270px">
	    <i class="bottom"><span>7</span></i>
	    <i class="bottom"><span>8</span></i>
	    <i class="bottom"><span>9</span></i>
	    <br>
	    <i class="bottom"><span>4</span></i>
	    <i class="bottom"><span>5</span></i>
	    <i class="bottom"><span>6</span></i>
	    <br>
	    <i class="bottom"><span>1</span></i>
	    <i class="bottom"><span>2</span></i>
	    <i class="bottom"><span>3</span></i>
	    <br>
	    <i class="bottom"><span>0</span></i>
	    <i class="dele"><span></span></i>
	    <i class="rest"><span></span></i>
	</div>
	<div class="toubi_1" style="display:none;height: 121px;" id="msg_display">
		<div class="toubi_11" style="height: 121px">
			<div class="print-tikect"><span class="like-red" id="err_msg"></span></div>
			<div style="height:10px;"></div>
			<div><span id="tip_time" style="margin-left:200px;">2</span>秒后返回主界面</div>
		</div>
	</div>
</body>
</html>
